package lock.deadlock;

import java.math.BigDecimal;

/**
 * 测试一下
 *
 * @author 86155
 * @date 2025/08/16
 */
public class Test {

    public static void main(String[] args) {
        Account from = new Account("1111", new BigDecimal(2000));
        Account to = new Account("222", new BigDecimal(2000));

        //创建线程去执行
        // 循环创建线程 A -> B ; B -> A 各一百个线程
        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                try {
                    TransferMoney.transferMoney(from,to,new BigDecimal(5));
                } catch (Exception e) {
                    return;
                }
            }).start();

            new Thread(() -> {
                try {
                    TransferMoney.transferMoney(to,from,new BigDecimal(5));
                } catch (Exception e) {
                    return;
                }
            }).start();


        }
    }
}
